local g = vim.g
local cmd = vim.cmd

local hl = function(thing, opts)
  vim.api.nvim_set_hl(0, thing, opts)
end

cmd("highlight clear")
if vim.fn.exists("syntax on") then
  cmd("syntax reset")
end

-- g.colors_name = "dark_dungeon"

-- check if TODO highlight is working
-- if is not working please install comment module for Treesitier
-- :TSInstall comment

-- == Vanilla highlights ==
hl("Todo",       { ctermfg="black", ctermbg="magenta" } )
hl('Normal',     { ctermfg="white", ctermbg=none      } )
hl('Comment',    { ctermfg="blue", ctermbg=none       } )
hl('NonText',    { ctermfg='yellow', ctermbg=none     } )
hl('Visual',     { ctermfg=none, ctermbg="black"      } )
hl('Cursor',     { ctermfg=none, ctermbg="black"      } )
hl('Function',   { ctermfg='blue', ctermbg=none       } )
hl('Folded',     { ctermfg="cyan", ctermbg=none       } )
hl('SignColumn', { ctermfg="white", ctermbg="black"   } )
hl('CursorLine', { ctermfg="white", ctermbg=none      } )
hl('Type',      { ctermfg='blue',   ctermbg=none  } )
hl('Special',   { ctermfg='green',  ctermbg=none } )
hl('Statement', { ctermfg='yellow', ctermbg=none } )
hl('Constant',  { ctermfg='red',    ctermbg=none } )
hl('String',    { ctermfg='green',  ctermbg=none } )
hl('Number',    { ctermfg='cyan',   ctermbg=none } )

-- == tabs ==
hl('TabLine',     { ctermbg='black', ctermbg="black"} )
hl('TabLineFill', { ctermfg='white', ctermbg='black'} )
hl('TabLineSel',  { ctermfg='blue',  ctermbg='black'} )

-- == pmenu ==
hl('Pmenu',      { ctermfg="white", ctermbg='black'} )
hl('PmenuSel',   { ctermfg="black", ctermbg='blue'}  )
hl('PmenuSbar',  { ctermfg="green", ctermbg='black'} )
hl('PmenuThumb', { ctermfg="white", ctermbg='black'} )

hl('FloatBorder', { ctermfg='green', ctermbg='black' })

-- == treesitier ==
hl('TSFunction',    { ctermfg="green" } )
hl('TSFuncBuiltin', { ctermfg="green" } )
hl('TSFuncMacro',   { ctermfg="green" } )

hl('TSVariable',        { ctermfg="magenta" } )
hl('TSVariableBuiltin', { ctermfg="magenta" } )

hl('TSType',        { ctermfg="blue" } )
hl('TSTypeBuiltin', { ctermfg="blue" } )

hl('TSNumber',    { ctermfg="cyan" } )
hl('TSFloat',     { ctermfg="cyan" } )
hl('TSBoolean',   { ctermfg="red" } )
hl('TSCharacter', { ctermfg="magenta" } )

hl('TSString',       { ctermfg="green" } )
hl('TSStringRegex',  { ctermfg="green" } )
hl('TSStringEscape', { ctermfg="green" } )

hl('TSConstant',     { ctermfg="red" } )
hl('TSConstBuiltin', { ctermfg="red" } )
hl('TSConstMacro',   { ctermfg="red" } )

hl('TSKeyword',         { ctermfg="blue"  } )
hl('TSKeywordOperator', { ctermfg="blue" } )
hl('TSKeywordFunction', { ctermfg="blue" } )

hl('TSInclude', { ctermfg="blue" } )

hl('TSError',          { ctermfg="red" } )
hl('TSText',           { ctermfg="white" } )
hl('TSPunctDelimiter', { ctermfg="green" } )

-- hl('TSPunctBracket',       { ctermbg= , ctermfg=none } )
-- hl('TSPunctSpecial',       { ctermbg= , ctermfg=none } )
-- hl('TSAnnotation',         { ctermbg= , ctermfg=none } )
-- hl('TSAttribute',          { ctermbg= , ctermfg=none } )
hl('TSNamespace',          { ctermbg="blue" , ctermfg=none } )
-- hl('TSParameter ',         { ctermbg= , ctermfg=none } )
-- hl('TSParameterReference', { ctermbg= , ctermfg=none } )
-- hl('TSMethod',             { ctermbg= , ctermfg=none } )
-- hl('TSField',              { ctermbg= , ctermfg=none } )
-- hl('TSProperty',           { ctermbg= , ctermfg=none } )
-- hl('TSConstructor',        { ctermbg= , ctermfg=none } )
-- hl('TSConditional',        { ctermbg= , ctermfg=none } )
-- hl('TSRepeat',             { ctermbg= , ctermfg=none } )
-- hl('TSLabel',              { ctermbg= , ctermfg=none } )
hl('TSOperator',           { ctermbg="red" , ctermfg=none } )
-- hl('TSException',          { ctermbg= , ctermfg=none } )
-- hl('TSStructure',          { ctermbg= , ctermfg=none } )
-- hl('TSStrong',             { ctermbg= , ctermfg=none } )
-- hl('TSEmphasis',           { ctermbg= , ctermfg=none } )
hl('TSUnderline',          { ctermbg="yellow" , ctermfg=none } )
-- hl('TSTitle',              { ctermbg= , ctermfg=none } )
-- hl('TSLiteral',            { ctermbg= , ctermfg=none } )
-- hl('TSURI',                { ctermbg= , ctermfg=none } )
-- hl('TSTag',                { ctermbg= , ctermfg=none } )
-- hl('TSTagDelimiter',       { ctermbg= , ctermfg=none } )

-- == lualine ==
hl('lualine_a_insert',   { ctermfg="black", ctermbg="green"   } )
hl('lualine_a_normal',   { ctermfg="black", ctermbg="white"   } )
hl('lualine_a_visual',   { ctermfg="black", ctermbg="magenta" } )
hl('lualine_a_replace',  { ctermfg="black", ctermbg="red"     } )
hl('lualine_a_command',  { ctermfg="black", ctermbg="yellow"  } )
hl('lualine_a_terminal', { ctermfg="black", ctermbg="magenta" } )

hl('lualine_b_insert',   { ctermfg="black", ctermbg="green"   } )
hl('lualine_b_normal',   { ctermfg="black", ctermbg="blue"    } )
hl('lualine_b_visual',   { ctermfg="black", ctermbg="magenta" } )
hl('lualine_b_replace',  { ctermfg="black", ctermbg="red"     } )
hl('lualine_b_command',  { ctermfg="black", ctermbg="yellow"  } )
hl('lualine_b_terminal', { ctermfg="black", ctermbg="magenta" } )

hl('lualine_c_inactive', { ctermfg="white", ctermbg=none   } )
hl('lualine_c_normal',   { ctermfg="blue", ctermbg=none    } )
hl('lualine_c_visual',   { ctermfg="magenta", ctermbg=none } )
hl('lualine_c_insert',   { ctermfg="green", ctermbg=none   } )
hl('lualine_c_replace',  { ctermfg="red", ctermbg=none     } )
hl('lualine_c_command',  { ctermfg="yellow", ctermbg=none  } )
hl('lualine_c_terminal', { ctermfg="magenta", ctermbg=none } )

hl('lualine_b_diagnostics_error_insert', { ctermfg="black", ctermbg="red" } )
hl('lualine_b_diagnostics_error_normal', { ctermfg="black", ctermbg="red" } )
hl('lualine_b_diagnostics_error_visual', { ctermfg="black", ctermbg="red" } )

hl('lualine_b_diagnostics_warn_insert',  { ctermfg="black", ctermbg="yellow" } )
hl('lualine_b_diagnostics_warn_normal',  { ctermfg="black", ctermbg="yellow" } )
hl('lualine_b_diagnostics_warn_visual',  { ctermfg="black", ctermbg="yellow" } )

hl('lualine_b_diagnostics_hint_insert',  { ctermfg="black", ctermbg="blue" } )
hl('lualine_b_diagnostics_hint_normal',  { ctermfg="black", ctermbg="blue" } )
hl('lualine_b_diagnostics_hint_visual',  { ctermfg="black", ctermbg="blue" } )

hl('lualine_b_diagnostics_info_insert',  { ctermfg="black", ctermbg="green" } )
hl('lualine_b_diagnostics_info_normal',  { ctermfg="black", ctermbg="green" } )
hl('lualine_b_diagnostics_info_visual',  { ctermfg="black", ctermbg="green" } )

hl('lualine_b_diff_added_command',  { ctermfg="black", ctermbg="green" } ) 
hl('lualine_b_diff_added_insert',   { ctermfg="black", ctermbg="green" } ) 
hl('lualine_b_diff_added_normal',   { ctermfg="black", ctermbg="green" } ) 
hl('lualine_b_diff_added_visual',   { ctermfg="black", ctermbg="green" } ) 
hl('lualine_b_diff_added_replace',  { ctermfg="black", ctermbg="green" } ) 
hl('lualine_b_diff_added_inactive', { ctermfg="black", ctermbg="green" } ) 
hl('lualine_b_diff_added_terminal', { ctermfg="black", ctermbg="green" } ) 

hl('lualine_b_diff_modified_command',  { ctermfg="black", ctermbg="magenta" } ) 
hl('lualine_b_diff_modified_insert',   { ctermfg="black", ctermbg="magenta" } ) 
hl('lualine_b_diff_modified_normal',   { ctermfg="black", ctermbg="magenta" } ) 
hl('lualine_b_diff_modified_visual',   { ctermfg="black", ctermbg="magenta" } ) 
hl('lualine_b_diff_modified_replace',  { ctermfg="black", ctermbg="magenta" } ) 
hl('lualine_b_diff_modified_inactive', { ctermfg="black", ctermbg="magenta" } ) 
hl('lualine_b_diff_modified_terminal', { ctermfg="black", ctermbg="magenta" } ) 

hl('lualine_b_diff_removed_command',  { ctermfg="black", ctermbg="red" } ) 
hl('lualine_b_diff_removed_insert',   { ctermfg="black", ctermbg="red" } ) 
hl('lualine_b_diff_removed_normal',   { ctermfg="black", ctermbg="red" } ) 
hl('lualine_b_diff_removed_visual',   { ctermfg="black", ctermbg="red" } ) 
hl('lualine_b_diff_removed_replace',  { ctermfg="black", ctermbg="red" } ) 
hl('lualine_b_diff_removed_inactive', { ctermfg="black", ctermbg="red" } ) 
hl('lualine_b_diff_removed_terminal', { ctermfg="black", ctermbg="red" } ) 

-- == diagnostic ==
hl('DiagnosticError', { ctermfg='red',    ctermbg=none } )
hl('DiagnosticWarn',  { ctermfg='yellow', ctermbg=none } )
hl('DiagnosticHint',  { ctermfg='blue',   ctermbg=none } )
hl('DiagnosticInfo',  { ctermfg='cyan',   ctermbg=none } )


-- == telescope ==
hl('TelescopeBorder',        { ctermfg='green'   } )
hl('TelescopeMatching',      { ctermfg='green'   } )
hl('TelescopeTitle',         { ctermfg='green'   } )
hl('TelescopePreviewBorder', { ctermfg="magenta" } )
hl('TelescopePreviewTitle',  { ctermfg="magenta" } )

-- hl('TelescopeMultiIcon',              { ctermfg="", ctermbg=none } )
hl('TelescopeMultiSelection',         { ctermfg="magenta", ctermbg=none } )
hl('TelescopeNormal',                 { ctermfg="blue", ctermbg=none } )

-- hl('TelescopePreviewBlock',           { ctermfg="", ctermbg=none } )
-- hl('TelescopePreviewCharDev',         { ctermfg="", ctermbg=none } )
hl('TelescopePreviewDate',            { ctermfg="blue", ctermbg=none } )
hl('TelescopePreviewDirectory',       { ctermfg="cyan", ctermbg=none } )
hl('TelescopePreviewExecute',         { ctermfg="green", ctermbg=none } )
-- hl('TelescopePreviewGroup',           { ctermfg="", ctermbg=none } )
-- hl('TelescopePreviewHyphen',          { ctermfg="", ctermbg=none } )
-- hl('TelescopePreviewLine',            { ctermfg="", ctermbg=none } )
-- hl('TelescopePreviewLink',            { ctermfg="", ctermbg=none } )
hl('TelescopePreviewMatch',           { ctermfg="green", ctermbg=none } )
-- hl('TelescopePreviewMessage',         { ctermfg="", ctermbg=none } )
-- hl('TelescopePreviewMessageFillchar', { ctermfg="", ctermbg=none } )
hl('TelescopePreviewNormal',          { ctermfg="blue", ctermbg=none } )
-- hl('TelescopePreviewPipe',            { ctermfg="", ctermbg=none } )
-- hl('TelescopePreviewRead',            { ctermfg="", ctermbg=none } )
hl('TelescopePreviewSize',            { ctermfg="green", ctermbg=none } )
-- hl('TelescopePreviewSocket',          { ctermfg="", ctermbg=none } )
-- hl('TelescopePreviewSticky',          { ctermfg="", ctermbg=none } )
hl('TelescopePreviewUser',            { ctermfg="white", ctermbg=none } )
-- hl('TelescopePreviewWrite',           { ctermfg="", ctermbg=none } )

hl('TelescopePromptBorder',           { ctermfg="red", ctermbg=none } )
-- hl('TelescopePromptCounter',          { ctermfg="", ctermbg=none } )
hl('TelescopePromptNormal',           { ctermfg="blue", ctermbg=none } )
hl('TelescopePromptPrefix',           { ctermfg="green", ctermbg=none } )
-- hl('TelescopePromptTitle',            { ctermfg="", ctermbg=none } )

hl('TelescopeResultsBorder',          { ctermfg="yellow", ctermbg=none } )
hl('TelescopeResultsClass',           { ctermfg="green", ctermbg=none } )
hl('TelescopeResultsComment',         { ctermfg="blue", ctermbg=none } )
hl('TelescopeResultsConstant',        { ctermfg="red", ctermbg=none } )
hl('TelescopeResultsDiffAdd',         { ctermfg="green", ctermbg=none } )
hl('TelescopeResultsDiffChange',      { ctermfg="magenta", ctermbg=none } )
hl('TelescopeResultsDiffDelete',      { ctermfg="red", ctermbg=none } )
hl('TelescopeResultsDiffUntracked',   { ctermfg="blue", ctermbg=none } )
hl('TelescopeResultsField',           { ctermfg="blue", ctermbg=none } )
hl('TelescopeResultsFileIcon',        { ctermfg="green", ctermbg=none } )
hl('TelescopeResultsFunction',        { ctermfg="blue", ctermbg=none } )
-- hl('TelescopeResultsIdentifier',      { ctermfg="", ctermbg=none } )
-- hl('TelescopeResultsLineNr',          { ctermfg="", ctermbg=none } )
-- hl('TelescopeResultsMethod',          { ctermfg="", ctermbg=none } )
hl('TelescopeResultsNormal',          { ctermfg="blue", ctermbg=none } )
hl('TelescopeResultsNumber',          { ctermfg="cyan", ctermbg=none } )
hl('TelescopeResultsOperator',        { ctermfg="red", ctermbg=none } )
hl('TelescopeResultsSpecialComment',  { ctermfg="blue", ctermbg=none } )
hl('TelescopeResultsStruct',          { ctermfg="green", ctermbg=none } )
-- hl('TelescopeResultsTitle',           { ctermfg="", ctermbg=none } )
hl('TelescopeResultsVariable',        { ctermfg="cyan", ctermbg=none } )

-- hl('TelescopeSelection',              { ctermfg="", ctermbg=none } )
-- hl('TelescopeSelectionCaret',         { ctermfg="", ctermbg=none } )


-- == completion menu highlight ==
hl('CmpItemAbbr',                     { ctermfg="white" ,   ctermbg=none } )
hl('CmpItemAbbrDefault',              { ctermfg="white" ,   ctermbg=none } )
hl('CmpItemAbbrDeprecated',           { ctermfg="magenta" , ctermbg=none } )
hl('CmpItemAbbrDeprecatedDefault',    { ctermfg="magenta" , ctermbg=none } )
hl('CmpItemAbbrMatch',                { ctermfg="green" ,   ctermbg=none } )
hl('CmpItemAbbrMatchDefault',         { ctermfg="green" ,   ctermbg=none } )
hl('CmpItemAbbrMatchFuzzy',           { ctermfg="green" ,   ctermbg=none } )
hl('CmpItemAbbrMatchFuzzyDefault',    { ctermfg="green" ,   ctermbg=none } )
hl('CmpItemKind',                     { ctermfg="white" ,   ctermbg=none } )
hl('CmpItemKindClass',                { ctermfg="green" ,   ctermbg=none } )
hl('CmpItemKindClassDefault',         { ctermfg="green" ,   ctermbg=none } )
hl('CmpItemKindColor',                { ctermfg="magenta" , ctermbg=none } )
hl('CmpItemKindColorDefault',         { ctermfg="magenta" , ctermbg=none } )
hl('CmpItemKindConstant',             { ctermfg="red" ,     ctermbg=none } )
hl('CmpItemKindConstantDefault',      { ctermfg="red" ,     ctermbg=none } )
-- hl('CmpItemKindConstructor',          { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindConstructorDefault',   { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindDefault',              { ctermfg= , ctermbg=none } )
hl('CmpItemKindEnum',                 { ctermfg="yellow", ctermbg=none } )
hl('CmpItemKindEnumDefault',          { ctermfg="yellow", ctermbg=none } )
-- hl('CmpItemKindEnumMember',           { ctermfg= , ctermbg=none} )
-- hl('CmpItemKindEnumMemberDefault',    { ctermfg= , ctermbg=none} )
-- hl('CmpItemKindEvent',                { ctermfg= , ctermbg=none} )
-- hl('CmpItemKindEventDefault',         { ctermfg= , ctermbg=none} )
-- hl('CmpItemKindField',                { ctermfg= , ctermbg=none} )
-- hl('CmpItemKindFieldDefault',         { ctermfg= , ctermbg=none} )
hl('CmpItemKindFile',                 { ctermfg="white" , ctermbg=none } )
hl('CmpItemKindFileDefault',          { ctermfg="white" , ctermbg=none } )
hl('CmpItemKindFolder',               { ctermfg="cyan" , ctermbg=none } )
hl('CmpItemKindFolderDefault',        { ctermfg="cyan" , ctermbg=none } )
hl('CmpItemKindFunction',             { ctermfg="blue" , ctermbg=none } )
hl('CmpItemKindFunctionDefault',      { ctermfg="blue" , ctermbg=none } )
hl('CmpItemKindInterface',            { ctermfg="red" , ctermbg=none } )
hl('CmpItemKindInterfaceDefault',     { ctermfg="red" , ctermbg=none } )
hl('CmpItemKindKeyword',              { ctermfg="white" , ctermbg=none } )
hl('CmpItemKindKeywordDefault',       { ctermfg="white" , ctermbg=none } )
-- hl('CmpItemKindMethod',               { ctermfg= , ctermbg=none} )
-- hl('CmpItemKindMethodDefault',        { ctermfg= , ctermbg=none} )
hl('CmpItemKindModule',               { ctermfg="yellow" , ctermbg=none } )
hl('CmpItemKindModuleDefault',        { ctermfg="yellow" , ctermbg=none } )
-- hl('CmpItemKindOperator',             { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindOperatorDefault',      { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindProperty',             { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindPropertyDefault',      { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindReference',            { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindReferenceDefault',     { ctermfg= , ctermbg=none } )
hl('CmpItemKindSnippet',              { ctermfg="white" , ctermbg=none } )
hl('CmpItemKindSnippetDefault',       { ctermfg="white" , ctermbg=none } )
hl('CmpItemKindStruct',               { ctermfg="yellow", ctermbg=none } )
hl('CmpItemKindStructDefault',        { ctermfg="yellow", ctermbg=none } )
hl('CmpItemKindText',                 { ctermfg="white" , ctermbg=none } )
hl('CmpItemKindTextDefault',          { ctermfg="white" , ctermbg=none } )
-- hl('CmpItemKindTypeParameter',        { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindTypeParameterDefault', { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindUnit',                 { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindUnitDefault',          { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindValue',                { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindValueDefault.'         { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindVariable.'             { ctermfg= , ctermbg=none } )
-- hl('CmpItemKindVariableDefault.'      { ctermfg= , ctermbg=none } )
-- hl('CmpItemMenu.'                     { ctermfg= , ctermbg=none } )
-- hl('CmpItemMenuDefault.'              { ctermfg= , ctermbg=none } )
-- hl('CmpItermAbbr.'                    { ctermfg= , ctermbg=none } )
-- hl('CmpItermAbbrMatch.'               { ctermfg= , ctermbg=none } )
-- hl('CmpItermKind.'                    { ctermfg= , ctermbg=none } )
-- hl('CmpItermKindClass.'               { ctermfg= , ctermbg=none } )


-- gitsigns
hl('GitSignsAdd',                { ctermfg="green" , ctermbg=none ,} )
-- hl('GitSignsAddInline',          { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsAddLn',              { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsAddLnInline',        { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsAddLnVirtLn',        { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsAddLnVirtLnInLine',  { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsAddNr',              { ctermfg= , ctermbg=none ,} )
hl('GitSignsChange',             { ctermfg="magenta", ctermbg=none ,} )
-- hl('GitSignsChangeInline',       { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsChangeLn',           { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsChangeLnInline',     { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsChangeNr',           { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsChangeVirtLn',       { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsChangeVirtLnInLine', { ctermfg= , ctermbg=none ,} )
hl('GitSignsDelete',             { ctermfg="red", ctermbg=none ,} )
-- hl('GitSignsDeleteInline',       { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsDeleteLnInline',     { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsDeleteNr',           { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsDeleteVirtLn',       { ctermfg= , ctermbg=none ,} )
-- hl('GitSignsDeleteVirtLnInLine', { ctermfg= , ctermbg=none ,} )
